{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Work with DataFrames and pandas\n",
    "\n",
    "Before we start, we need to import the required modules. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pandas import DataFrame"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "First, I like to show you how to create a new DataFrame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "0  1  2  3  4"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = DataFrame([[1,2,3,4]], columns=[\"A\", \"B\", \"C\", \"D\"])\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The amount of list entries in the ``columns`` list must equal every list in the first parameter, otherwise an Exception is thrown.\n",
    "\n",
    "The following example shows, how to create a DataFrame using a list."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "0  1  2  3  4\n",
       "1  2  3  4  5\n",
       "2  3  4  5  6\n",
       "3  4  5  6  7\n",
       "4  5  6  7  8"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rows = []\n",
    "for e in range(0,5):\n",
    "    rows.append([e+1,e+2,e+3,e+4])\n",
    "    \n",
    "df = DataFrame(rows, columns=[\"A\", \"B\", \"C\", \"D\"])\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A DataFrame is always organized in labled columns and rows. Each row has an index value, which is created using a  `for` loop in the previous example. There are also ways to work with custom index values and/or multi-level index values, but this is beyond the scope of this notebook. \n",
    "\n",
    "## get information about the structure of the DataFrame\n",
    "\n",
    "To get a list with all index values from a DataFrame, use"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=5, step=1)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This attribute returns a `RangeIndex` that can be used like a list (technically it is not a list but anyway)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for e in df.index:\n",
    "    print(e)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " To get a normal python list, you can use the `tolist()` function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index.tolist()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This function is availalbe on many attributes within the DataFrame. We can the following expression to get a list with all column names from the DataFrame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['A', 'B', 'C', 'D'], dtype='object')"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['A', 'B', 'C', 'D']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns.tolist()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## common functions in DataFrames\n",
    "\n",
    "The following cells contain some useful functions when working with DataFrames (e.g. view x rows from the top or bottom).\n",
    "\n",
    "Some computation functions, like `sum()` can be used on multiple levels within the DataFrame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "0  1  2  3  4\n",
       "1  2  3  4  5"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "3  4  5  6  7\n",
       "4  5  6  7  8"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.tail(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A    15\n",
       "B    20\n",
       "C    25\n",
       "D    30\n",
       "dtype: int64"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.A.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.0"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.A.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A    3.0\n",
       "B    4.0\n",
       "C    5.0\n",
       "D    6.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.median()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>5.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>5.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>3.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>6.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>1.581139</td>\n",
       "      <td>1.581139</td>\n",
       "      <td>1.581139</td>\n",
       "      <td>1.581139</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>4.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>2.000000</td>\n",
       "      <td>3.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>5.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>3.000000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>6.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>4.000000</td>\n",
       "      <td>5.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>7.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>5.000000</td>\n",
       "      <td>6.000000</td>\n",
       "      <td>7.000000</td>\n",
       "      <td>8.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              A         B         C         D\n",
       "count  5.000000  5.000000  5.000000  5.000000\n",
       "mean   3.000000  4.000000  5.000000  6.000000\n",
       "std    1.581139  1.581139  1.581139  1.581139\n",
       "min    1.000000  2.000000  3.000000  4.000000\n",
       "25%    2.000000  3.000000  4.000000  5.000000\n",
       "50%    3.000000  4.000000  5.000000  6.000000\n",
       "75%    4.000000  5.000000  6.000000  7.000000\n",
       "max    5.000000  6.000000  7.000000  8.000000"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## delete rows\n",
    "\n",
    "A row within a DataFrame can be deleted using the `drop()` function. The function expects the index label of the row that should be dropped.\n",
    "\n",
    "The index values within the DataFrame are persistent, e.g. when deleting the row with the index 2, the length of the index values will decrease, but you still have the index values 0, 1, 3 and 4."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "0  1  2  3  4\n",
       "1  2  3  4  5\n",
       "2  3  4  5  6\n",
       "3  4  5  6  7\n",
       "4  5  6  7  8"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index.tolist()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "0  1  2  3  4\n",
       "1  2  3  4  5\n",
       "3  4  5  6  7\n",
       "4  5  6  7  8"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "1  2  3  4  5\n",
       "2  3  4  5  6\n",
       "4  5  6  7  8"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.drop([0,3])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## select and edit values\n",
    "\n",
    "There are multiple ways to retrive data from a DataFrame. First, you can select rows by the index value using `ix`. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "A    1\n",
       "B    2\n",
       "C    3\n",
       "D    4\n",
       "Name: 0, dtype: int64"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser = df.ix[0]\n",
    "ser"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The resulting data type is a `Series`, which is a one-dimensional labeled array. You can access the data in a similar way as with the DataFrame."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(ser)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser[\"A\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['A', 'B', 'C', 'D'], dtype='object')"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ser.keys()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false
   },
   "source": [
    "Within DataFrames and Series, you can work with multiple DataTypes. They could be native to python (like `int` or `strings`) or complex objects, like an `ipaddress.IPv4Address`. The DataType of an element an/or a row is stored in the `dtype` attribute:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dtype('int64')"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.ix[0][\"A\"].dtype"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The data types behind the scenes of pandas is build on numpy. I won't go into more details at this point. If you like to learn more about numpy, please take a look at the [numpy homepage](http://www.numpy.org/)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "An alternative way to select data from the DataFrame is the `loc` function. You can access data either using labels or using boolean arrays.\n",
    "\n",
    "First, lets have a look on the `loc`\n",
    " function using labels."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "0  1  2  3  4\n",
       "1  2  3  4  5\n",
       "2  3  4  5  6\n",
       "3  4  5  6  7\n",
       "4  5  6  7  8"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[1, \"B\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can also modify values in the DataFrame with the `loc` function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>100</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A    B  C  D\n",
       "0  1    2  3  4\n",
       "1  2  100  4  5\n",
       "2  3    4  5  6\n",
       "3  4    5  6  7\n",
       "4  5    6  7  8"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[1, \"B\"] = 100\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following function can be used to iterate over the rows in a DataFrame:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ROW AT INDEX 0:\n",
      "A    1\n",
      "B    2\n",
      "C    3\n",
      "D    4\n",
      "Name: 0, dtype: int64\n",
      "\n",
      "\n",
      "ROW AT INDEX 1:\n",
      "A      2\n",
      "B    100\n",
      "C      4\n",
      "D      5\n",
      "Name: 1, dtype: int64\n",
      "\n",
      "\n",
      "ROW AT INDEX 2:\n",
      "A    3\n",
      "B    4\n",
      "C    5\n",
      "D    6\n",
      "Name: 2, dtype: int64\n",
      "\n",
      "\n",
      "ROW AT INDEX 3:\n",
      "A    4\n",
      "B    5\n",
      "C    6\n",
      "D    7\n",
      "Name: 3, dtype: int64\n",
      "\n",
      "\n",
      "ROW AT INDEX 4:\n",
      "A    5\n",
      "B    6\n",
      "C    7\n",
      "D    8\n",
      "Name: 4, dtype: int64\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "for index, row in df.iterrows():\n",
    "    print(\"ROW AT INDEX %d:\\n%s\\n\\n\" % (index, row))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Filter DataFrame\n",
    "\n",
    "At some point, you need just some data from a DataFrame. Filter data is quite easy, but you need to keep in mind, that a seperate DataFrame with the expected data is created during that process."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "3  4  5  6  7"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = df[df.A == 4]\n",
    "df2  # copy with the selected data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>100</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A    B  C  D\n",
       "0  1    2  3  4\n",
       "1  2  100  4  5\n",
       "2  3    4  5  6\n",
       "3  4    5  6  7\n",
       "4  5    6  7  8"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df  # original DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>100</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>50</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "      <td>8</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A    B   C  D\n",
       "0  1    2   3  4\n",
       "1  2  100   4  5\n",
       "2  3    4   5  6\n",
       "3  4    5  50  7\n",
       "4  5    6   7  8"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[3, \"C\"] = 50\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>5</td>\n",
       "      <td>6</td>\n",
       "      <td>7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   A  B  C  D\n",
       "3  4  5  6  7"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In many cases, i need to work with text data. First, lets create a DataFrame with some text values."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Test</td>\n",
       "      <td>Another Test</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>String</td>\n",
       "      <td>Another String</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        A               B\n",
       "0    Test    Another Test\n",
       "1  String  Another String"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = DataFrame([\n",
    "        [\"Test\", \"Another Test\"],\n",
    "        [\"String\", \"Another String\"],\n",
    "    ], columns=[\"A\", \"B\"])\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You can filter based on string values using the index value as `str`. We use `contains` in this example to receive all rows that contains the string `Test` in column A. The `contains` function is based on the `re.search` function from the standard regular expression library."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Test</td>\n",
       "      <td>Another Test</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      A             B\n",
       "0  Test  Another Test"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[df.A.str.contains(\"Test\")]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are also additional operations like `match` (relis on `re.match`), `startswith` and `endswith` available."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "At last, I'll like to show you how to convert a DataFrame to a dictionary."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'A': {3: 4}, 'B': {3: 5}, 'C': {3: 6}, 'D': {3: 7}}"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# convert the rows to dictionaries that include the index of the row\n",
    "df2.to_dict()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'A': [4], 'B': [5], 'C': [6], 'D': [7]}"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# convert the rows to flat lists\n",
    "df2.to_dict(orient=\"list\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create DataFrames from different sources\n",
    "\n",
    "You can create DataFrames from different sources, e.g. CSV files, Excel Files and even the local clipboard. A detailed explanation of all possiblities are available in the [pandas IO documentation](http://pandas.pydata.org/pandas-docs/stable/io.html)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <th>Test</th>\n",
       "      <td>Another</td>\n",
       "      <td>Test</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              A     B\n",
       "0 Test  Another  Test"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# copy the last table output within this workbook\n",
    "clipboard_df = pd.read_clipboard()\n",
    "clipboard_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "It's also possible to extract tables from HTML pages, like the Cisco EoL notes. The following statement requires the following additional libraries:\n",
    "\n",
    "* lxml\n",
    "* BeautifulSoup4\n",
    "* html5lib\n",
    "\n",
    "The result is a list with all tables found in the HTML sourcecode."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "list"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "html_dfs = pd.read_html(\"http://www.cisco.com/c/en/us/products/collateral/switches/catalyst-2960-series-switches/eos-eol-notice-c51-730121.html\")\n",
    "type(html_dfs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Milestone</td>\n",
       "      <td>Definition</td>\n",
       "      <td>Date</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>End-of-Life Announcement Date</td>\n",
       "      <td>The date the document that announces the end-o...</td>\n",
       "      <td>October 31, 2013</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>End-of-Sale Date</td>\n",
       "      <td>The last date to order the product through Cis...</td>\n",
       "      <td>October 31, 2014</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Last Ship Date: HW</td>\n",
       "      <td>The last-possible ship date that can be reques...</td>\n",
       "      <td>January 29, 2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>End of SW Maintenance Releases Date: HW</td>\n",
       "      <td>The last date that Cisco Engineering may relea...</td>\n",
       "      <td>October 31, 2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>End of Vulnerability/Security Support: HW</td>\n",
       "      <td>The last date that Cisco Engineering may relea...</td>\n",
       "      <td>October 30, 2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>End of Routine Failure Analysis Date: HW</td>\n",
       "      <td>The last-possible date a routine failure analy...</td>\n",
       "      <td>October 31, 2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>End of New Service Attachment Date: HW</td>\n",
       "      <td>For equipment and software that is not covered...</td>\n",
       "      <td>October 31, 2015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>End of Service Contract Renewal Date: HW</td>\n",
       "      <td>The last date to extend or renew a service con...</td>\n",
       "      <td>January 29, 2019</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>Last Date of Support: HW</td>\n",
       "      <td>The last date to receive applicable service an...</td>\n",
       "      <td>October 31, 2019</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                           0  \\\n",
       "0                                  Milestone   \n",
       "1              End-of-Life Announcement Date   \n",
       "2                           End-of-Sale Date   \n",
       "3                         Last Ship Date: HW   \n",
       "4    End of SW Maintenance Releases Date: HW   \n",
       "5  End of Vulnerability/Security Support: HW   \n",
       "6   End of Routine Failure Analysis Date: HW   \n",
       "7     End of New Service Attachment Date: HW   \n",
       "8   End of Service Contract Renewal Date: HW   \n",
       "9                   Last Date of Support: HW   \n",
       "\n",
       "                                                   1                 2  \n",
       "0                                         Definition              Date  \n",
       "1  The date the document that announces the end-o...  October 31, 2013  \n",
       "2  The last date to order the product through Cis...  October 31, 2014  \n",
       "3  The last-possible ship date that can be reques...  January 29, 2015  \n",
       "4  The last date that Cisco Engineering may relea...  October 31, 2015  \n",
       "5  The last date that Cisco Engineering may relea...  October 30, 2017  \n",
       "6  The last-possible date a routine failure analy...  October 31, 2015  \n",
       "7  For equipment and software that is not covered...  October 31, 2015  \n",
       "8  The last date to extend or renew a service con...  January 29, 2019  \n",
       "9  The last date to receive applicable service an...  October 31, 2019  "
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "html_dfs[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>End-of-Sale Product Part Number</td>\n",
       "      <td>Product Description</td>\n",
       "      <td>Replacement Product Part Number</td>\n",
       "      <td>Replacement Product Description</td>\n",
       "      <td>Additional Information</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>WS-C2960-24-S</td>\n",
       "      <td>Catalyst 2960 24 10/100 LAN Lite Image</td>\n",
       "      <td>WS-C2960+24TC-S</td>\n",
       "      <td>Catalyst 2960 Plus 24 10/100 + 2 T/SFP LAN Lite</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>WS-C2960-24LC-S</td>\n",
       "      <td>Catalyst 2960 24 10/100 (8 PoE) + 2 T/SFP LAN ...</td>\n",
       "      <td>WS-C2960+24LC-S</td>\n",
       "      <td>Catalyst 2960 Plus 24 10/100 (8 PoE) + 2 T/SFP...</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>WS-C2960-24LT-L</td>\n",
       "      <td>Catalyst 2960 24 10/100 (8 PoE)+ 2 1000BT LAN ...</td>\n",
       "      <td>WS-C2960+24LC-L</td>\n",
       "      <td>Catalyst 2960 Plus 24 10/100 (8 PoE) + 2 T/SFP...</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>WS-C2960-24PC-L</td>\n",
       "      <td>Catalyst 2960 24 10/100 PoE + 2 T/SFP LAN Base...</td>\n",
       "      <td>WS-C2960+24PC-L</td>\n",
       "      <td>Catalyst 2960 Plus 24 10/100 PoE + 2 T/SFP LAN...</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>WS-C2960-24PC-S</td>\n",
       "      <td>Catalyst 2960 24 10/100 PoE + 2 T/SFP LAN Lite...</td>\n",
       "      <td>WS-C2960+24PC-S</td>\n",
       "      <td>Catalyst 2960 Plus 24 10/100 PoE + 2 T/SFP LAN...</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>WS-C2960-24TC-L</td>\n",
       "      <td>Catalyst 2960 24 10/100 + 2T/SFP LAN Base Image</td>\n",
       "      <td>WS-C2960+24TC-L</td>\n",
       "      <td>Catalyst 2960 Plus 24 10/100 + 2T/SFP LAN Base</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>WS-C2960-24TC-S</td>\n",
       "      <td>Catalyst 2960 24 10/100 + 2 T/SFP LAN Lite Image</td>\n",
       "      <td>WS-C2960+24TC-S</td>\n",
       "      <td>Catalyst 2960 Plus 24 10/100 + 2 T/SFP LAN Lite</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>WS-C2960-24TT-L</td>\n",
       "      <td>Catalyst 2960 24 10/100 + 2 1000BT LAN Base Image</td>\n",
       "      <td>WS-C2960+24TC-L</td>\n",
       "      <td>Catalyst 2960 Plus 24 10/100 + 2T/SFP LAN Base</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>WS-C2960-48PST-L</td>\n",
       "      <td>Catalyst 2960 48 10/100 PoE + 2 1000BT +2 SFP ...</td>\n",
       "      <td>WS-C2960+48PST-L</td>\n",
       "      <td>Catalyst 2960 Plus 48 10/100 PoE + 2 1000BT +2...</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>WS-C2960-48PST-S</td>\n",
       "      <td>Catalyst 2960 48 10/100 PoE + 2 1000BT +2 SFP ...</td>\n",
       "      <td>WS-C2960+48PST-S</td>\n",
       "      <td>Catalyst 2960 Plus 48 10/100 PoE + 2 1000BT +2...</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>WS-C2960-48TC-L</td>\n",
       "      <td>Catalyst 2960 48 10/100 + 2 T/SFP LAN Base Image</td>\n",
       "      <td>WS-C2960+48TC-L</td>\n",
       "      <td>Catalyst 2960 Plus 48 10/100 + 2 T/SFP LAN Base</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>WS-C2960-48TC-S</td>\n",
       "      <td>Catalyst 2960 48 10/100 + 2 T/SFP LAN Lite Image</td>\n",
       "      <td>WS-C2960+48TC-S</td>\n",
       "      <td>Catalyst 2960 Plus 48 10/100 + 2 T/SFP LAN Lite</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>WS-C2960-48TT-L</td>\n",
       "      <td>Catalyst 2960 48 10/100 + 2 1000BT LAN Base Image</td>\n",
       "      <td>WS-C2960+48TC-L</td>\n",
       "      <td>Catalyst 2960 Plus 48 10/100 + 2 T/SFP LAN Base</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>WS-C2960-48TT-S</td>\n",
       "      <td>Catalyst 2960 48 10/100 + 2 1000BT LAN Lite Image</td>\n",
       "      <td>WS-C2960+48TC-S</td>\n",
       "      <td>Catalyst 2960 Plus 48 10/100 + 2 T/SFP LAN Lite</td>\n",
       "      <td>-</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                  0  \\\n",
       "0   End-of-Sale Product Part Number   \n",
       "1                     WS-C2960-24-S   \n",
       "2                   WS-C2960-24LC-S   \n",
       "3                   WS-C2960-24LT-L   \n",
       "4                   WS-C2960-24PC-L   \n",
       "5                   WS-C2960-24PC-S   \n",
       "6                   WS-C2960-24TC-L   \n",
       "7                   WS-C2960-24TC-S   \n",
       "8                   WS-C2960-24TT-L   \n",
       "9                  WS-C2960-48PST-L   \n",
       "10                 WS-C2960-48PST-S   \n",
       "11                  WS-C2960-48TC-L   \n",
       "12                  WS-C2960-48TC-S   \n",
       "13                  WS-C2960-48TT-L   \n",
       "14                  WS-C2960-48TT-S   \n",
       "\n",
       "                                                    1  \\\n",
       "0                                 Product Description   \n",
       "1              Catalyst 2960 24 10/100 LAN Lite Image   \n",
       "2   Catalyst 2960 24 10/100 (8 PoE) + 2 T/SFP LAN ...   \n",
       "3   Catalyst 2960 24 10/100 (8 PoE)+ 2 1000BT LAN ...   \n",
       "4   Catalyst 2960 24 10/100 PoE + 2 T/SFP LAN Base...   \n",
       "5   Catalyst 2960 24 10/100 PoE + 2 T/SFP LAN Lite...   \n",
       "6     Catalyst 2960 24 10/100 + 2T/SFP LAN Base Image   \n",
       "7    Catalyst 2960 24 10/100 + 2 T/SFP LAN Lite Image   \n",
       "8   Catalyst 2960 24 10/100 + 2 1000BT LAN Base Image   \n",
       "9   Catalyst 2960 48 10/100 PoE + 2 1000BT +2 SFP ...   \n",
       "10  Catalyst 2960 48 10/100 PoE + 2 1000BT +2 SFP ...   \n",
       "11   Catalyst 2960 48 10/100 + 2 T/SFP LAN Base Image   \n",
       "12   Catalyst 2960 48 10/100 + 2 T/SFP LAN Lite Image   \n",
       "13  Catalyst 2960 48 10/100 + 2 1000BT LAN Base Image   \n",
       "14  Catalyst 2960 48 10/100 + 2 1000BT LAN Lite Image   \n",
       "\n",
       "                                  2  \\\n",
       "0   Replacement Product Part Number   \n",
       "1                   WS-C2960+24TC-S   \n",
       "2                   WS-C2960+24LC-S   \n",
       "3                   WS-C2960+24LC-L   \n",
       "4                   WS-C2960+24PC-L   \n",
       "5                   WS-C2960+24PC-S   \n",
       "6                   WS-C2960+24TC-L   \n",
       "7                   WS-C2960+24TC-S   \n",
       "8                   WS-C2960+24TC-L   \n",
       "9                  WS-C2960+48PST-L   \n",
       "10                 WS-C2960+48PST-S   \n",
       "11                  WS-C2960+48TC-L   \n",
       "12                  WS-C2960+48TC-S   \n",
       "13                  WS-C2960+48TC-L   \n",
       "14                  WS-C2960+48TC-S   \n",
       "\n",
       "                                                    3                       4  \n",
       "0                     Replacement Product Description  Additional Information  \n",
       "1     Catalyst 2960 Plus 24 10/100 + 2 T/SFP LAN Lite                       -  \n",
       "2   Catalyst 2960 Plus 24 10/100 (8 PoE) + 2 T/SFP...                       -  \n",
       "3   Catalyst 2960 Plus 24 10/100 (8 PoE) + 2 T/SFP...                       -  \n",
       "4   Catalyst 2960 Plus 24 10/100 PoE + 2 T/SFP LAN...                       -  \n",
       "5   Catalyst 2960 Plus 24 10/100 PoE + 2 T/SFP LAN...                       -  \n",
       "6      Catalyst 2960 Plus 24 10/100 + 2T/SFP LAN Base                       -  \n",
       "7     Catalyst 2960 Plus 24 10/100 + 2 T/SFP LAN Lite                       -  \n",
       "8      Catalyst 2960 Plus 24 10/100 + 2T/SFP LAN Base                       -  \n",
       "9   Catalyst 2960 Plus 48 10/100 PoE + 2 1000BT +2...                       -  \n",
       "10  Catalyst 2960 Plus 48 10/100 PoE + 2 1000BT +2...                       -  \n",
       "11    Catalyst 2960 Plus 48 10/100 + 2 T/SFP LAN Base                       -  \n",
       "12    Catalyst 2960 Plus 48 10/100 + 2 T/SFP LAN Lite                       -  \n",
       "13    Catalyst 2960 Plus 48 10/100 + 2 T/SFP LAN Base                       -  \n",
       "14    Catalyst 2960 Plus 48 10/100 + 2 T/SFP LAN Lite                       -  "
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "html_dfs[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
